/**
 * 
 */

package com.pp.admin.main.client.tab.objectpages;

import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.pp.admin.common.client.beans.Contact;
import com.pp.admin.common.client.beans.User;
import com.pp.admin.common.client.helper.AdminHorizontalPanel;
import com.pp.admin.common.client.i18.I18;

/**
 * @author pandurang
 */
public class CompleteUser extends VerticalPanel implements I18 {

	private UserInfo user = null;

	private ContactInfo contact = null;

	private PhoneInfo phones = null;

	private EmailInfo emails = null;

	

	public CompleteUser(User userBean) {
		user = new UserInfo(userBean);
		contact = new ContactInfo(userBean.getContact());
		phones = new PhoneInfo(userBean.getContact().getPhoneContacts());

		emails = new EmailInfo(userBean.getContact().getEmailContacts());
		init();
	}

	public CompleteUser() {
		user = new UserInfo();

		contact = new ContactInfo();

		phones = new PhoneInfo();

		emails = new EmailInfo();
		init();
	}

	public void init() {
		this.add(user);
		this.setCellHorizontalAlignment(user,
				HasHorizontalAlignment.ALIGN_CENTER);
		this.add(new HTML("<hr>"));
		this.add(new Label(myConstants.contactinfo() + " : "));
		AdminHorizontalPanel contactPanel = new AdminHorizontalPanel();
		contactPanel.add(contact);
		contactPanel.addVerticalLine();
		contactPanel.add(phones);
		contactPanel.addVerticalLine();
		contactPanel.add(emails);
		this.add(contactPanel);
		this.setCellHorizontalAlignment(contactPanel,
				HasHorizontalAlignment.ALIGN_CENTER);

	}

	public User getUser() {

		User bnUser = user.getUser();
		Contact bnContact = contact.getContact();
		bnContact.setPhoneContacts(phones.getPhoneList());
		bnContact.setEmailContacts(emails.getEmailList());
		bnUser.setContact(bnContact);

		return bnUser;
	}
}
